package com.xpqh.ksg.modular.overseas.controller;

import com.xpqh.ksg.base.BaseController;
import com.xpqh.ksg.base.BaseResponseDTO;
import com.xpqh.ksg.common.persistence.model.KsgOverseasCaseBlog;
import com.xpqh.ksg.modular.overseas.dto.KsgOverseasCaseBlogListReqDTO;
import com.xpqh.ksg.modular.overseas.dto.KsgOverseasCaseBlogListRespDTO;
import com.xpqh.ksg.modular.overseas.service.IKsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping(value = "ksg/overseasCaseBlogList")
public class KsgOverseasCaseBlogListController extends BaseController {

    @Autowired
    private IKsgService ksgService;

    @RequestMapping(method = RequestMethod.POST)
    public BaseResponseDTO process(@Valid @RequestBody KsgOverseasCaseBlogListReqDTO req) throws Exception {

        KsgOverseasCaseBlogListRespDTO respDTO = new KsgOverseasCaseBlogListRespDTO();
        List<KsgOverseasCaseBlog> caseBlogList = ksgService.getCaseBlogList(req.getType(), req.getPageNo(), req.getPageSize());
        respDTO.setCaseBlogList(caseBlogList);
        respDTO.setCount(ksgService.getCaseBlogListCount(req.getType()));
        return renderResultOk(respDTO);
    }
}
